//
//  ViewController.m
//  04-Control
//
//  Created by dllo on 16/7/19.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.
//    UISwitch *swich = [[UISwitch alloc] init];
//    swich.frame = CGRectMake(100, 100, 1, 1);
//    swich.backgroundColor = [UIColor redColor];//switch宽和高不影响
////    [self.view addSubview:swich];
//    swich.onTintColor = [UIColor blueColor];
//    swich.tintColor = [UIColor blackColor];
//    swich.thumbTintColor = [UIColor grayColor];
//    [swich setOn:YES animated:NO];
//    swich.on = NO;
//    
//    UISlider *slider = [[UISlider alloc] init];
//    slider.frame = CGRectMake(100, 200, 150, 30);
//    slider.backgroundColor = [UIColor redColor];
//    [self.view addSubview:slider];
//    slider.minimumValue = 1.0;
//    slider.maximumValue = 2;
//    slider.minimumTrackTintColor = [UIColor greenColor];//已经移动过的区域
//    slider.maximumTrackTintColor = [UIColor purpleColor];//没移动到的区域
//    [slider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
    
//    UIImageView *imageView = [[UIImageView alloc] init];
//    imageView.frame = CGRectMake(20, 20, 100, 100);
//    imageView.image = [UIImage imageNamed:@"1"];
//    [self.view addSubview:imageView];
//    slider.minimumValueImage = [UIImage imageNamed:@"1"];
//    slider.maximumValueImage = [UIImage imageNamed:@"1"];
    
//    UISegmentedControl *segment = [[UISegmentedControl alloc] init];
//    segment.frame = ;
//    slider.value = 0.5; //当前滑块的值
//    slider.continuous = NO;
//    slider.continuous = YES;
    
    
//    设置进度条滑块右边的图片
//    [slider setMaximumTrackImage:[UIImage imageNamed:@"1"] forState:UIControlStateNormal];
//    [slider setMinimumTrackImage:[UIImage imageNamed:@"2"] forState:UIControlStateNormal];
//    设置进度条滑块图片
//    [slider setThumbImage:[UIImage imageNamed:@"3"] forState:UIControlStateNormal];
//    [self.view addSubview:slider];
    
    
//    segment.frame = CGRectMake(100, 100, 140, 100);
//    segment.backgroundColor = [UIColor redColor];
//    [self.view addSubview:segment];
    
    
    UISegmentedControl *segment =[[UISegmentedControl alloc] initWithItems:@[@"dfdsfsdf",@"vcmnv",@"reererr",@"cvcbbb"]];
    NSLog(@"%@",NSStringFromCGRect(segment.frame));
    segment.frame = CGRectMake(20, 20, 335, 50);
    [self.view addSubview: segment];
//    momentary 设置为YES，如果点击选中没有选中的效果，默认为NO
    segment.momentary = YES;
    NSUInteger numberOfSegments = segment.numberOfSegments;
    NSLog(@"%lu",numberOfSegments);
    
//    练习：点击button，使segment添加新的标题
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(20, 20, 200, 200);
    [self.view addSubview:button];
    [button addTarget:self action:@selector(addSegmentTitle:) forControlEvents:UIControlEventTouchUpInside];
    
//    不能被选中
    
    
    UIPageControl *pageControl = [[UIPageControl alloc] init];
    pageControl.frame = CGRectMake(10, 10, 100, 100);
    pageControl.backgroundColor = [UIColor redColor];
    pageControl.numberOfPages = 3;
    [self.view addSubview:pageControl];
    pageControl.currentPage = 0;
//    关闭系统事件page的切换，直到调用

    
    
  
}

- (void)addSegmentTitle:(UIButton *)button
{
    UISegmentedControl *segment = [self.view viewWithTag:1000];
    [segment insertSegmentWithTitle:@"df" atIndex:1 animated:YES];
}




- (void)sliderAction:(UISlider *)slider
{
     NSLog(@"%f",slider.value);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
